<template>
  <md-snackbar style="top:0;margin:0px auto;" :md-duration="Infinity" :md-active="showmsg" md-persistent>
    <span :style="'color:'+ fcolor">{{ msgcontent }}</span>
    <md-button class="md-primary" @click="closemsg">关闭</md-button>
  </md-snackbar>

</template>
<script>
export default {
  data () {
    return {
      showmsg: false,
      msgtype: '', // 1:success  2:error 3:warning
      msgcontent: ''
    }
  },
  methods: {
    showmg: function (type, text) {
      this.msgtype = type
      this.showmsg = true
      this.msgcontent = text
    },
    closemsg: function() {
      this.showmsg = false
    }
  },
  computed: {
    fcolor: function () {
      if (this.msgtype == 1) {
        return 'green'
      } else if (this.msgtype == 2) {
        return 'red'
      } else if (this.msgtype == 3) {
        return 'amber'
      } else {
        return 'white'
      }
    }
  }
}
</script>
